const activitiesDao = require("../dao/activitiesDao");

exports.getList = async (req, res) => {
  const activities = await activitiesDao.getAll();
  res.json(activities);
};

exports.add = async (req, res) => {
  const activity = req.body;
  const result = await activitiesDao.add(activity);
  res.json({ code: 200, message: "添加成功", activity: result });
};

exports.update = async (req, res) => {
  const { id } = req.params;
  const activity = req.body;
  const result = await activitiesDao.update(id, activity);
  res.json({ code: 200, message: "更新成功", activity: result });
};

exports.delete = async (req, res) => {
  const { id } = req.params;
  await activitiesDao.remove(id);
  res.json({ code: 200, message: "删除成功" });
};
